package com.example.news.iteam;

import android.content.Intent;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import com.example.news.R;
import com.example.news.bean.OneIteamBean;

import java.util.ArrayList;

public class Rendian_Iteam extends AppCompatActivity {

    private ArrayList<OneIteamBean> list;
    private TextView tv_1;
    private TextView tv_2;
    private ImageView img_1;
    private String name = null;
    private String index = null;
    private Toolbar iteam_one_toolbar;
    private TextView tv_3;
    private ImageView img_3;
    private TextView tv_4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_iteam_one);
        initView();
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        index = bundle.getString("i");
        name = bundle.getString("name");
        Toast.makeText(Rendian_Iteam.this, index + name, Toast.LENGTH_SHORT).show();
        list = new ArrayList<>();
        init();
        initEne();
    }

    private void initEne() {
        tv_1.setText(name);
        for (int i = 0; i < list.size(); i++) {
            if (String.valueOf(index).equals(String.valueOf(list.get(i).getIndex()))) {
                tv_2.setText(list.get(i).getI());
                img_1.setImageResource(list.get(i).getImg_1());
                tv_3.setText(list.get(i).getJ());
                img_3.setImageResource(list.get(i).getImg_2());
                tv_4.setText(list.get(i).getA());
            }
        }
    }

    private void init() {
        list.add(new OneIteamBean("原标题：新能源汽车市场遇冷： 造车新势力如何跨越寒冬？\n" +
                "","","", R.drawable.xin1, R.drawable.xin3, 1));
        list.add(new OneIteamBean("", "", "", R.drawable.a, 0, 2));
    }

    private void initView() {

        Toolbar toolbar = findViewById(R.id.iteam_one_toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        tv_1 = (TextView) findViewById(R.id.tv_1);
        tv_2 = (TextView) findViewById(R.id.tv_2);
        img_1 = (ImageView) findViewById(R.id.img_1);
        tv_2.setMovementMethod(ScrollingMovementMethod.getInstance());
        iteam_one_toolbar = (Toolbar) findViewById(R.id.iteam_one_toolbar);
        tv_3 = (TextView) findViewById(R.id.tv_3);
        img_3 = (ImageView) findViewById(R.id.img_3);
        tv_4 = (TextView) findViewById(R.id.tv_4);
    }
}


